#ifndef CONVERTER_FRAME_CONVERTER_H
#define CONVERTER_FRAME_CONVERTER_H

#include "ColorDiffCalc.h"
#include <common/Palette.h>
#include <common/CachedTransform.h>
#include <common/UintSeq.h>
#include <memory>
#include <cstdint>

class FrameConverter
{
public:
    explicit FrameConverter(const std::shared_ptr<IPalette>& palette_, const std::shared_ptr<IColorDiffCalc>& cdc_);
    enum ImageDataType
    {
        RGB = 0,
        RGBA = 1
    };
    bool Convert(uint8_t* data, size_t length, ImageDataType type, IUintSeq& outData);
private:
    std::shared_ptr<IColorDiffCalc> cdc;
    std::shared_ptr<IPalette> palette;
    std::shared_ptr<CachedTransform<Color, size_t>> colorIndexCache;
    static size_t GetImageDataOffset(ImageDataType type);
    static Color GetImageDataColor(const uint8_t* dataP, ImageDataType type);
};


#endif //CONVERTER_FRAME_CONVERTER_H
